<template>
  <div class="app-container">
    <div class="filter-container">
      <div class="filter-container">
        <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="请输入姓名" v-model="listQuery.name"></el-input>
        <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
      </div>
    </div>
    <el-table :data="teamStaffList" border style="width: 100%;" >
      <el-table-column prop="id" label="ID" >
      </el-table-column>
      <el-table-column prop="name" label="姓名">
      </el-table-column>
      <el-table-column prop="pmessage" label="介绍">
      </el-table-column>
      <el-table-column prop="post" label="身份">
      </el-table-column>
      <!--<el-table-column prop="pimg" label="照片">-->
      <!--</el-table-column>-->
      <!--<el-table-column align="center" label="操作"  class-name="small-padding fixed-width">-->
        <!--<template slot-scope="scope">-->
          <!--<el-button size="small" type="danger" @click="deleteTeamStaffById(scope.row)">删除</el-button>-->
        <!--</template>-->
      <!--</el-table-column>-->
    </el-table>
    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.size" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import { fetchTeamStaffList, deleteTeamStaffById } from '@/api/user'
  import waves from '@/directive/waves'
  export default {
    directives: {
      waves
    },
    data() {
      return {
        teamStaffList: null,
        total: null,
        user: {
          id: null
        },
        listQuery: {
          page: 1,
          size: 10,
          uid: undefined
        }
      }
    },
    created() {
      this.getUserList()
    },
    methods: {
      getUserList() {
        fetchTeamStaffList(this.listQuery).then(response => {
          this.teamStaffList = response.data.rows
          this.total = response.data.total
        })
      },
      handleFilter() {
        this.listQuery.page = 1
        this.getUserList()
      },
      deleteTeamStaffById(row) {
        this.user.id = row.id
        deleteTeamStaffById(this.user)
        this.$message({
          message: '操作成功',
          type: 'success'
        })
        this.getUserList()
      },
      handleSizeChange(val) {
        this.listQuery.size = val
        this.getUserList()
      },
      handleCurrentChange(val) {
        this.listQuery.page = val
        this.getUserList()
      }
    }
  }
</script>

<style scoped>
  .app-container{
    padding: 30px;
  }
</style>

